package com.itheima.demo4;

import java.util.concurrent.ConcurrentHashMap;

public class MyConcurrentHashMapDemo {
    public static void main(String[] args) throws InterruptedException {
        ConcurrentHashMap<String,String> map = new ConcurrentHashMap<>();

        new Thread(()->{
            for (int i = 0; i < 100; i++) {
                map.put(i+"",i+"");
            }
        }).start();

        new Thread(()->{
            for (int i = 100; i < 200; i++) {
                map.put(i+"",i+"");
            }
        }).start();

        Thread.sleep(1000);

        map.forEach((k,v)-> System.out.println(k+"="+v));
    }
}
